--
-- Author:      name
-- DateTime:    2018-04-21 15:27:55
-- Description: 服务间共享配置数据

local skynet = require "skynet"
local configtool = require "configtool"

local setting_file = skynet.getenv("setting_file")
print("________setting_file__",setting_file)
	
--配置文件路径
-- local file_path = {
-- 	setting_cfg = setting_root..'service_setting',
-- }

--进程配置
local function load_service_setting( )
	-- local config = {}
	-- local gateip = skynet.getenv("gateip")
	-- local localip = getLocalIp() --取本地ip
	-- load_lua_file(file_path.setting_cfg, function(cfg)
	-- 	for module, svrs in pairs(cfg) do
	-- 		--print(module,"____________")
	-- 		for k,v in pairs(svrs) do
	-- 			if type(v) == 'table' then
	-- 				v.svr_id = k
	-- 			end
	-- 			if module == 'gatesvrs' then 
	-- 				v.ip = gateip
	-- 				if not v.ip or v.ip == '127.0.0.1' then
	-- 					v.ip = localip
	-- 				end
	-- 			end
	-- 		end
	-- 	end
	-- 	config = cfg
	-- end)

	local config = require(setting_file)
	for _,pro in pairs(config) do
		for k,v in pairs(pro) do 
			if type(v) == 'table' then
				v.svr_id = k				
			end
		end
	end
	-- print("___config__",config)
	configtool.share_new("setting_cfg", config)
end


--牛牛房间配置
local function load_niuniu_config()
	local config = require "lua_NiuniuTableList"
	configtool.share_new("niuniu_config",config)
end

--炸金花房间配置
local function load_zjh_config()
	local config = require "lua_ZjhTableList"
	configtool.share_new("zjh_config",config)	
end

--百家乐房间配置
local function load_bjl_config()
	local config = require "lua_BjlTableList"
	configtool.share_new("bjl_config",config)	
end



local function load_config()	
	load_service_setting()
	-- load_niuniu_config()
	-- load_zjh_config()
	-- load_bjl_config()

	-- --跑得快
	-- local config = require "lua_PdkTableList"
	-- configtool.share_new("pdk_config",config)		
	--中发白
	-- local config = require "lua_ZfbTableList"
	-- configtool.share_new("zfb_config",config)		
	--房卡跑得快玩法配置
	local config = require "lua_PdkRoomSet"
	configtool.share_new("pdk_room_set",config)		
end

skynet.start(function()
	configtool.begin()
	load_config()
	configtool.finish()
end)